#ifndef TEACHDIALOG_H
#define TEACHDIALOG_H

#include <QDialog>
#include <QLabel>
#include <QLineEdit>
#include <QObject>
#include <QTableWidget>
#include <models/databasemanager.h>
#include <models/teachmodel.h>
#include "custom/popupdialog.h"
#include "touchbutton.h"


class TeachDialog : public PopupDialog {
    Q_OBJECT
public:
    enum DialogType{
        ADD_DIALOG,
        EDIT_DIALOG
    };
    TeachDialog(DialogType type,TeachModel* model, int index,QWidget *parent = nullptr);
    void  saveJoint(int nID);
    void setName(QString strName);
    void addPoint(int execTime=1000,int waitTime=1000);
private slots:
    void onAddBtn();
    void closeDialog();
    void onOK();
private:
    QLineEdit *nameEdit;
    TouchButton *addPointButton;
    QTableWidget *tableWidget;
    TouchButton *okButton;
    TouchButton *cancelButton;
    QLabel *titleLabel;
    TouchButton *closeButton;
    QLabel *errorLabel;
    DialogType curType;
    QVector<TeachData> vTeachData;
    TeachModel* pCurmodel;
    QString strOldName;

    // QWidget interface
protected:
    void showEvent(QShowEvent *event);
    void hideEvent(QHideEvent *event);
};

#endif // TEACHDIALOG_H
